<!DOCTYPE html>
<html>
  <head>
    <title>用户登录</title>
    <% include inc/css.ejs %>
  </head>
  <body>
    <h1>登录</h1>
    <div>
        用户名：<input type="text" id="username" value="admin"/>
    </div>
    <div>
        密码：<input type="password" id="password" value="123456"/>
    </div>
    <div>
        <input type="button" id="loginBtn" value="登录"/>
    </div>
    <% include inc/js.ejs %>
    <script type="text/javascript">
        $(function() {
            $('#loginBtn').click(function() {
                var _username = $('#username');
                if(JUtil.isEmpty(_username.val())) {
                    _username.focus();
                    return;
                }
                var _password = $('#password');
                if(JUtil.isEmpty(_password.val())) {
                    _password.focus();
                    return;
                }
                JUtil.ajax({
                    url: '/sysUser/login',
                    data: {username: _username.val(), password: _password.val()},
                    success: function(json) {
                        if(json.code===0) {
                            location = '/sysUser/fv/main';
                        } else if(json.code === -1) alert(JUtil.msg.err);
                        else alert(json.message);
                    }
                });
            });
        });
    </script>
  </body>
</html>
